package jmine.tec.cluster.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import jmine.tec.persist.annotation.Alias;
import bancosys.tec.component.Documentation;
import bancosys.tec.persist.authorization.annotation.DisplayName;
import bancosys.tec.persist.bussobj.PersistableBusinessObject;

/**
 * Entidade que representa um nó num cluster.
 * 
 * @author ricardo
 * 
 */
@Entity
@Alias("CLSNOD")
@Table(name = "CLUSTER_NODE")
@DisplayName("ClusterNode")
@Documentation("TABELA QUE CONTEM OS NOS DE UM CLUSTER")
@SequenceGenerator(name = "SEQ_CLSNOD", sequenceName = "SEQ_CLSNOD")
public class ClusterNode extends PersistableBusinessObject {
	private Long id;
	private String hostname;
	private Long ping = 0L;

	/**
	 * @return o id do nó.
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_CLSNOD")
	@Documentation("CODIGO DO CLUSTER NODE")
	@Column(name = "COD_CLUSTER_NODE", nullable = false)
	public Long getId() {
		return this.id;
	}

	/**
	 * Setter do id do nó.
	 * 
	 * @param id
	 *            o id.
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * 
	 * @return o hostname
	 */
	@Documentation("HOSTNAME DO NO")
	@Column(name = "HOSTNAME", nullable = false)
	public String getHostname() {
		return this.hostname;
	}

	/**
	 * Setter do hostname
	 * 
	 * @param hostname
	 *            o hostname.
	 */
	public void setHostname(String hostname) {
		this.hostname = hostname;
	}

	/**
	 * 
	 * @return o contador de vida do nó.
	 */
	@Documentation("CONTADOR DE NUMERO DE HEART BEATS")
	@Column(name = "HEART_BEATS", nullable = false)
	public Long getPing() {
		return this.ping;
	}

	/**
	 * Setter do contador de vida do nó.
	 * 
	 * @param ping
	 *            o contador.
	 */
	public void setPing(Long ping) {
		this.ping = ping;
	}
}
